﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DAL;
using HomeStayWebCP.Models;
namespace HomeStayWebCP.Controllers
{
    public class HomeController : Controller
    {
       
        public ActionResult Index()
        {   
            PostModel model=new PostModel();
            ViewBag.ListOfTopLikePost = model.GetTopLikePost().ToList();
            ViewBag.ListNoPostInProvince = model.ListNoPostInProvince().ToList();
            if (HttpContext.Session != null) HttpContext.Session["Data"] = GetAllAddress();
            return View();
        }

        readonly AllAddressModel _allAddressModel = new AllAddressModel();

        public string[] GetAllAddress()
        {
            List<ListAllAddressProDis_View> listAllAddressDB = _allAddressModel.GetAllAddress();
            string[] allAddress = new string[listAllAddressDB.Count];
            int i = 0;
            foreach (var list in listAllAddressDB)
            {
                allAddress[i++] = list.Address;
            }
            return allAddress;
        }

    }
}
